package com.cjg.lock;

import java.util.concurrent.TimeUnit;

public class deadLock {
    public static void main(String[] args) {
        dead dead = new dead("a", "b");
        dead dead1 = new dead("b", "a");
        new Thread(dead).start();
        new Thread(dead1).start();
    }
}
class dead implements  Runnable{

    private String a;
    private String b;

    public dead(String a, String b){
        this.a=a;
        this.b=b;
    }

    @Override
    public void run() {
        synchronized (a){
            System.out.println(a+"==>"+b);
            try {
                TimeUnit.SECONDS.sleep(3);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            synchronized (b){

            }
        }

    }
}